home *** CD-ROM | disk | FTP | other *** search
- Path: news.MWCI.NET!usenet
- From: stuffle@pcii.net
- Newsgroups: comp.lang.c++
- Subject: Re: Overload >> vs. Write Met
- Date: 30 Jan 1996 19:48:46 GMT
- Organization: MidWest Communications, Inc.
- Message-ID: <4elsmu$n80@hihat.mwci.net>
- References: <60125190005$71C7@lasernet.com> <4els7t$n54@hihat.mwci.net>
- Reply-To: stuffle@pcii.net
- NNTP-Posting-Host: lan-pm1-30.pcii.net
- X-Newsreader: IBM NewsReader/2 v1.2.5
-
- In <4els7t$n54@hihat.mwci.net>, stuffle@pcii.net writes:
- >In <60125190005$71C7@lasernet.com>, GEORGE BOUTWELL <george_boutwell@lasernet.com> writes:
- >>Ok...
- >>
- >> Which is 'better' OOP 'Style', and/or 'Correctness' for
- >>Writing/Reading an Object's Data to/from Disk/Screen/Etc:
- >>
- >>Overloading the << and >>
- >>-or-
- >>writing a read method and a write method?
- >>
- >>Regards,
- >>
- >>George
- >>
- >> * OLX 1.53 * >ov++h+n AC*hanks for hanging up, dear.
- >
- >I would say "make it streamable!!" If for any other reason, simply because
- >it is a nice, object independent mechanism for writting to a stream. Plus, the
- >syntax is much cleaner.
- >
- >ex:
- >ostream os;
- >int i;
- >TObj1 to1; // TObj1 & TObj2 NOT related.
- >TObj2 to2;
-
- alright, lets try the end of this again (since my news reader cut it off last time).
-
- ostream os;
- int i;
- TObj1 to1; // TObj1 & TObj2 NOT related.
- TObj2 to2;
-
- // other code here.
-
- os << i << to1 << to2; // Nice and easy to read.
- // consistent interface for all objects writting
- // to the out stream.
-
- os << i; // Inconsistent interface between objects
- to1.write(os); // writting to the out stream. Not as obvious
- to2.write(os); // what is happening. Not as pretty.
-
- Just my personal opinion. Others (of course) may varry.
-
- \\\|///
- | ~ ~ |
- (- @ @ -)
- //------------------------oOOo----(_)----oOOo------------------------
- // Ken Sodemann (Stuffle) | Get Warped!!!
- // Stuffle@PCII.NET |
- // http://users.mwci.net/~stuffle/ |
- //-------------------------------------------------------------------
-
-